import { Catch, MidwayHttpError } from '@midwayjs/core';
import { Context } from '@midwayjs/koa';

export class MissTargetError extends MidwayHttpError {
  constructor(message: string) {
    super(message, 800);
  }
}
@Catch(MissTargetError)
export class MissTargetFilter {
  async catch(err: MissTargetError, ctx: Context) {
    ctx.status = err.status;
    return err.message;
  }
}
export class LoginError extends MidwayHttpError {
  constructor(message: string) {
    super(message, 777);
  }
}
@Catch(LoginError)
export class LoginFilter {
  async catch(err: MissTargetError, ctx: Context) {
    ctx.status = err.status;
    return err.message;
  }
}
export class AccountNumError extends MidwayHttpError {
  constructor(message: string) {
    super(message, 701);
  }
}
@Catch(AccountNumError)
export class AccountNumFilter {
  async catch(err: MissTargetError, ctx: Context) {
    ctx.status = err.status;
    return err.message;
  }
}
